package vmcs.simulationsystem;

import java.awt.*;
import java.awt.event.*;

import vmcs.*;
import vmcs.controller.TransactionController;
import vmcs.customer.CoinReceiver;
import vmcs.ui.interfacecontrol.ICustomerPanel;
import vmcs.ui.interfacecontrol.ISimulatorPanel;


/**
* CustomerPanel inherits from Dialog class from Abstract Tool Kit library class
* of Java. This class represents the customer panel which enables to insert coins, select
* brands, terminate transaction. It also provides following display functions:
* 1 display total money inserted;
* 2 indicate coin not valid;
* 3 indicate no change available;
* 4 display the value of the change to be collected;
* 5 display an icon representing the dispensed drink.
* 
* @version 3.0 29/09/2008
* @author  Team 3S - SE16
*/

public class CustomerSimulationPanel implements ICustomerPanel {      
    private Dialog dialog;       
    private CoinInputBox coinInput;
    private DrinkSelectionBox drinkInput;        
    private LabelledDisplay moneyInserted;
    private LabelledDisplay collectCoin;
    private LabelledDisplay collectCan;
    private WarningDisplay invalidCoin;
    private WarningDisplay noChangeAvail;
    private Button terminateBtn;

/**
* This constructor creates an instance of the Customer Panel. 
* It further creates Invalid Coin Display,No Change Available Display, 
* Refund/Change Tray Display, Total Money Inserted Display, Coin Input Box, 
* Drink Selection Box, Can Collection Box and Terminate Button. It receives
* the reference for transaction controller object as a parameter.
* @param fr Frame 
* @param tCtrl Transaction Controller
* @see TransactionController
*/     
    public CustomerSimulationPanel() { 
    }

/**
* Display the Customer Panel. This will be achieved by displaying the frame of 
* the panel and then sending messages to its constituent objects instructing 
* them to display themselves.
*/     
    @Override
    public void display() {
    	getDialog().setVisible(true);
    }

/**
* This operation remove the Customer Panel from the display. 
*/     
    public void closeDown() {
    	getDialog().dispose();
    }  

    @Override
    public void setCoinInputActive(boolean isActive) {
    	getCoinInput().setActive(isActive);
    }

    
    @Override
    public void setCollectCanValue(String value) {
    	getCollectCan().setValue(value);
    }
    
    @Override
    public void setCollectCoinValue(String value) {
    	getCollectCoin().setValue(value);
    }
    
    @Override
    public void updateDrinkInput(int brandIndex, int quatity, int price,String name){
    	getDrinkInput().update(brandIndex, quatity, price, name);
    }

    @Override
    public void setInvalidCoinState(boolean isOn) {
    	getInvalidCoin().setState(isOn);
    }
    
    @Override
    public void setMoneyInsertedValue(String value) {
    	getMoneyInserted().setValue(value);
    }
    
    @Override
    public void setNoChangeAvailState(boolean isOn){
		getNoChangeAvail().setState(isOn);
	}
    
    @Override
    public void setDrinkSelectionBoxState(int brandIndex, boolean active){
    	getDrinkInput().setState(brandIndex, active);
    }
    
    @Override
    public void setDrinkSelectionBoxItemState(int brandIndex, boolean active){
    	getDrinkInput().setItemState(brandIndex, active);
    }
    
    @Override
    public void setDrinkSelectionBoxActive(boolean active){
    	getDrinkInput().setActive(active);        	
    }

	public void setDialog(Dialog dialog) {
		this.dialog = dialog;
	}

	public Dialog getDialog() {
		return dialog;
	}

	public CoinInputBox getCoinInput() {
		return coinInput;
	}

	public void setCoinInput(CoinInputBox coinInput) {
		this.coinInput = coinInput;
	}

	public DrinkSelectionBox getDrinkInput() {
		return drinkInput;
	}

	public void setDrinkInput(DrinkSelectionBox drinkInput) {
		this.drinkInput = drinkInput;
	}

	public LabelledDisplay getMoneyInserted() {
		return moneyInserted;
	}

	public void setMoneyInserted(LabelledDisplay moneyInserted) {
		this.moneyInserted = moneyInserted;
	}

	public LabelledDisplay getCollectCoin() {
		return collectCoin;
	}

	public void setCollectCoin(LabelledDisplay collectCoin) {
		this.collectCoin = collectCoin;
	}

	public LabelledDisplay getCollectCan() {
		return collectCan;
	}

	public void setCollectCan(LabelledDisplay collectCan) {
		this.collectCan = collectCan;
	}

	public WarningDisplay getInvalidCoin() {
		return invalidCoin;
	}

	public void setInvalidCoin(WarningDisplay invalidCoin) {
		this.invalidCoin = invalidCoin;
	}

	public WarningDisplay getNoChangeAvail() {
		return noChangeAvail;
	}

	public void setNoChangeAvail(WarningDisplay noChangeAvail) {
		this.noChangeAvail = noChangeAvail;
	}

	public Button getTerminateBtn() {
		return terminateBtn;
	}

	public void setTerminateBtn(Button terminateBtn) {
		this.terminateBtn = terminateBtn;
	}
    

/**
* This operation returns WarningDisplay object to display.
* @return WarningDisplay
*/     

    /*
    public WarningDisplay getInvalidCoin() {
            return invalidCoin;
    }

    public Button getTerminateBtn() {
            return terminateBtn;
    }
	public DrinkSelectionBox getDrinkSelectionBox() {
		// TODO Auto-generated method stub
		return drinkInput;
	}
	*/


/**
* This operation returns reference for CoinInputBox object
* @return CoinInput
*/ 
    /*
    public CoinInputBox getCoinInput() {
           return coinInput;
    } 
    */

/**
* This operation returns the LabelledDisplay (Coin).
* @return collectCoin
*/         
     /*
    public LabelledDisplay getCollectCoin() {
            return collectCoin;
    }*/
    


/**
* This operation returns DrinkSelectionBox.
* @return DrinkSelectionBox
*/     
    /*
    public DrinkSelectionBox getDrinkInput() {
            return drinkInput;
    }*/


/**
* This operation returns the LabelledDisplay (Money Inserted).
* @return moneyInserted
*/     
    /*
    public LabelledDisplay getMoneyInserted() {
            return moneyInserted;
    }*/
}